<template>
    <div class="delivergoods">
        <el-dialog v-model="open" width="78%" align="left" style="position: relative;background-color: #f1f1f1;" draggable>
            <div class="mb-20 f20">
                <p>DeliverGoods</p>
            </div>
            <el-radio-group v-model="radio" class="ml-4" @change="changeRadio">
                <el-radio label="1" size="large"> Full delivery </el-radio>
                <el-radio label="2" size="large"> Partial delivery </el-radio>
            </el-radio-group>

            <el-table ref="deliverList" :data="orderInfoList" @selection-change="goodSelectAll" height="400"
                style="width:100%;border-radius: 20px;">
                <el-table-column type="selection" width="30" />
                <el-table-column fixed prop="product_name_pi" label="Model" width="180" />
                <el-table-column prop="Brand_name" label="Brand" />
                <el-table-column prop="price" label="Price" />
                <el-table-column prop="quantity" label="Qty 数量" />
                <el-table-column prop="OrdertaskQty" label="Qty 已订货数量" />
                <el-table-column prop="ShipQty" label="SQty已发货" />
                <el-table-column v-if="radio == '2'" prop=" pqty" label="PQty 部">
                    <template v-slot="pqty">
                        <el-input @input="() => { emits('changeInput', pqty.row) }"
                            :disabled="pqty.row.OrdertaskQty - pqty.row.ShipQty < 0 || pqty.row.OrdertaskQty - pqty.row.ShipQty == 0 ? true : false"
                            v-model="pqty.row.pqty" placeholder="请输入发货数量" />
                    </template>
                </el-table-column>
                <el-table-column prop="purchaserInfo" label="Purchaser" />
                <el-table-column prop="state_text" label="State" />
                <el-table-column prop="weight" label="Weight" />
                <el-table-column prop="leadingtime" label="Leading Time" />
            </el-table>
            <template #footer>
                <span class="dialog-footer">
                    <el-button @click="goodsAdd" type="primary"
                        style="border:1px solid #6193D2;color:#ffffff">confirm</el-button>
                    <el-button @click="closeWindow"
                        style="border:1px solid #6193D2;background-color:#ffffff;color:#6193D2">Cancel</el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>
  
<script  setup>
import { ref } from 'vue'
const emits = defineEmits(['changeRadio1', 'goodsAdd', 'changeInput', 'goodSelectAll'])
const props = defineProps({
    orderInfoList: Object
})
const deliverList = ref()
const open = ref(false)
const radio = ref('1')
const dialogopen = () => {
    open.value = true
}
const changeRadio = (x) => {
    emits('changeRadio1', x)
}
// 选项框值发生改变时触发，
const goodSelectAll = (val) => {
    emits('goodSelectAll', val)
}
const goodsAdd = () => {
    emits('goodsAdd', (radio.value === '1' ? 1 : 2))
}
const closeWindow = () => {
    open.value = false
    radio.value = '1'
}
defineExpose(
    {
        open,
        radio,
        deliverList,
        dialogopen
    }
)
</script>
<style lang="less">
.delivergoods {
    .el-dialog__body {
        padding-top: 5px;
    }

    .el-dialog__title {
        font-weight: bold;
        font-family: 'swis';
        font-size: 20px;
    }
}
</style>